package com.zuo.demo01.service.impl;


import com.zuo.demo01.dao.ConfigMapper;
import com.zuo.demo01.pojo.Config;
import com.zuo.demo01.service.ConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class ConfigServiceImpl implements ConfigService {

    @Autowired
    private ConfigMapper configMapper;

    @Override
    public Map<String, String> findAll() {
        List<Config> list = configMapper.findAll();
        Map<String,String> map = new HashMap<>();
        for (Config item :
                list) {
            map.put(item.getName(), item.getValue());
        }

        return map;
    }

    @Override
    public int update(Map<String, Object> map) {
        Date date = new Date(System.currentTimeMillis());
        map.put("updateTime",date);

        return configMapper.update(map);
    }
}
